#include <iostream>
#include <vector>
#include <string>
#include <cstring>

class MyStringList;
class MyString:public std::string
{
public:
    MyString(const char* s):std::string(s){}
    MyStringList Split(const char *delim);
};

class MyStringList:public std::vector<MyString>
{

};


MyStringList MyString::Split(const char *delim)
{
    char *copyStr = new char[this->size() + 1];
    strcpy(copyStr,this->c_str());
    MyStringList list;
    char *s = strtok(copyStr,delim);
    while(s != nullptr)
    {
        list.push_back(MyString(s));
        s = strtok(nullptr,delim);
    }
    delete copyStr;
    return list;
}



int main()
{
    auto list = MyString("jellp,dsd,sdjas12").Split(",");
    for(auto ite = list.begin(); ite != list.end(); ite++)
    {
        //向上转型
        std::cout<<*ite<<std::endl;
    }
    return 0;
}